from rest_framework.serializers import ModelSerializer
from apps.teachers.models import Teacher


class TeacherSerializer(ModelSerializer):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # 将模型类的某个字段修改为必须字段
        self.fields['job'].required = True
        self.fields['is_staff'].required = True

    class Meta:
        model = Teacher
        exclude = ('password', 'avatar')
        read_only_fields = ('username', 'nickname', 'name', 'telephone', 'email', 'is_superuser')
